/*--------------------------------------------------------------------------------------------------
Yatak Operation System Project Copyright 2012
Author : Ilya Churaev
Started : 3 May 2012		Updated : 3 May 2012
File Name : queue.h			Purpose : queue
--------------------------------------------------------------------------------------------------*/

#ifndef _QUEUE_H
#define _QUEUE_H

#ifdef __cplusplus
extern "C" {
#endif

#define MAX_QUEUE 256

#define countOnQueue(q) (q.count)
#define headOnQueue(q) ((q.count>0)? q.mem[q.head] : -1)
#define tailOnQueue(q) ((q.count>0)? q.mem[q.tail] : -1)

typedef struct
{
	char mem[MAX_QUEUE];
	int volatile head;
	int volatile tail;
	int volatile count;
}queue_t;

void initQueue(queue_t *q);
void enqueue(queue_t *q, char c);
char dequeue(queue_t *q); 
char enqueueUndo(queue_t *q);

#ifdef __cplusplus
}
#endif

#endif
